#/////////////////////////////////////////////////////////////////////////////////
# WARRANTY: NONE. THIS PROGRAM WAS WRITTEN AS "SHAREWARE" AND IS AVAILABLE AS IS
# AND MAY NOT WORK AS ADVERTISED IN ALL ENVIRONMENTS. THERE IS NO
# SUPPORT FOR THIS PROGRAM
# NOTE: YOU ARE STRONGLY ADVISED TO BACKUP YOUR DESIGN
# BEFORE RUNNING THIS PROGRAM
# TCL file: capMenuUtil.tcl
# contains OrCAD Capture Menu utlities
#
# You can run the script in the Capture TCL command window .
#/////////////////////////////////////////////////////////////////////////////////
#package require TCL 8.2
#package provide capMenuUtil 1.0
package provide capTCLMenu 1.0

puts "hello world1"

proc Login2 { pLib } {
puts "hello world2"
exec "C:/WINDOWS/system32/notepad.exe"
}

namespace eval ::capTCLMenu {


proc addPageAccessoryMenu { } {
# AddAccessoryMenu <User menu under Accessories> <SubMenu under user menu> <TCL callback 
#handler with 2 parameters pPage and pOcc> 
		AddAccessoryMenu "PLM Menu" "Login" "::capTCLMenu::Login"
		AddAccessoryMenu "PLM Menu" "FindDoc" "::capTCLMenu::FindDoc"
		AddAccessoryMenu "PLM Menu" "CheckInDoc" "::capTCLMenu::CheckInDoc"
		AddAccessoryMenu "PLM Menu" "ImportDoc" "::capTCLMenu::ImportDoc"
		AddAccessoryMenu "PLM Menu" "AddMaterial" "::capTCLMenu::AddMaterial"
		AddAccessoryMenu "PLM Menu" "ImPortDocToPrjOut" "::capTCLMenu::ImPortDocToPrjOut"
		AddAccessoryMenu "PLM Menu" "ImPortDocToTaskOut" "::capTCLMenu::ImPortDocToTaskOut"
		AddAccessoryMenu "PLM Menu" "MaterialMatch" "::capTCLMenu::MaterialMatch"
		AddAccessoryMenu "PLM Menu" "UpdatePropertys" "::capTCLMenu::UpdatePropertys"
}
#菜单中方法名不能重复，否则会以第一个为准
proc addDesignAccessoryMenu { } {
# AddAccessoryMenu <User menu under Accessories> <SubMenu under user menu> <TCL callback 
#handler with 1 parameter pLib>
		AddAccessoryMenu "PLM Menu" "Login" "Login2"
		AddAccessoryMenu "PLM Menu" "FindDoc" "::capTCLMenu::FindDocInDesign"
		AddAccessoryMenu "PLM Menu" "CheckInDoc" "::capTCLMenu::CheckInDocInDesign"
		AddAccessoryMenu "PLM Menu" "ImportDoc" "::capTCLMenu::ImportDocInDesign"
		AddAccessoryMenu "PLM Menu" "AddMaterial" "::capTCLMenu::AddMaterialInDesign"
		AddAccessoryMenu "PLM Menu" "ImPortDocToPrjOut" "::capTCLMenu::ImPortDocToPrjOutInDesign"
		AddAccessoryMenu "PLM Menu" "ImPortDocToTaskOut" "::capTCLMenu::ImPortDocToTaskOutInDesign"
		AddAccessoryMenu "PLM Menu" "MaterialMatch" "::capTCLMenu::MaterialMatchInDesign"
		AddAccessoryMenu "PLM Menu" "UpdatePropertys" "::capTCLMenu::UpdatePropertysInDesign"
}
# '&'符号可以使该语句异步运行
proc Login { pLib } {
puts "hello world"
exec "C:/WINDOWS/system32/notepad.exe"
}

proc FindDoc { pLib pOcc} {
exec "Kingdee.PLM.SystemConverter.exe" "FindDoc,OrCAD" &
}
proc CheckInDoc { pLib pOcc} {
UpdateProperty
exec "Kingdee.PLM.SystemConverter.exe" "ShowMassage,OrCAD" &
exec "Kingdee.PLM.SystemConverter.exe" "CheckInDoc,OrCAD" &
}
proc ImportDoc { pLib pOcc} {
UpdateProperty
exec "Kingdee.PLM.SystemConverter.exe" "ShowMassage,OrCAD" &
exec "Kingdee.PLM.SystemConverter.exe" "ImportDoc,OrCAD" &
}
proc AddMaterial { pLib pOcc} {
exec "Kingdee.PLM.SystemConverter.exe" "AddMaterial,OrCAD" &
}
proc ImPortDocToPrjOut { pLib pOcc} {
UpdateProperty
exec "Kingdee.PLM.SystemConverter.exe" "ShowMassage,OrCAD" &
exec "Kingdee.PLM.SystemConverter.exe" "ImportToProOut,OrCAD" &
}
proc ImPortDocToTaskOut { pLib pOcc} {
UpdateProperty
exec "Kingdee.PLM.SystemConverter.exe" "ShowMassage,OrCAD" &
exec "Kingdee.PLM.SystemConverter.exe" "ImportToTaskOut,OrCAD" &
}
proc MaterialMatch { pLib pOcc } {
	exec "Kingdee.PLM.SystemConverter.exe" "MaterialMatch,OrCAD" &
}
proc UpdatePropertys { pLib pOcc } {
	UpdateProperty  
	exec "Kingdee.PLM.SystemConverter.exe" "ShowMassage,OrCAD" &
}




proc FindDocInDesign { pLib } {
exec "Kingdee.PLM.SystemConverter.exe" "FindDoc,OrCAD" &
}
proc CheckInDocInDesign { pLib } {
UpdateProperty
exec "Kingdee.PLM.SystemConverter.exe" "ShowMassage,OrCAD" &
exec "Kingdee.PLM.SystemConverter.exe" "CheckInDoc,OrCAD" &
}
proc ImportDocInDesign { pLib } {
UpdateProperty
exec "Kingdee.PLM.SystemConverter.exe" "ShowMassage,OrCAD" &
exec "Kingdee.PLM.SystemConverter.exe" "ImportDoc,OrCAD" &
}
proc AddMaterialInDesign { pLib } {
exec "Kingdee.PLM.SystemConverter.exe" "AddMaterial,OrCAD" &
}
proc ImPortDocToPrjOutInDesign { pLib } {
UpdateProperty
exec "Kingdee.PLM.SystemConverter.exe" "ShowMassage,OrCAD" &
exec "Kingdee.PLM.SystemConverter.exe" "ImportToProOut,OrCAD" &
}
proc ImPortDocToTaskOutInDesign { pLib } {
UpdateProperty
exec "Kingdee.PLM.SystemConverter.exe" "ShowMassage,OrCAD" &
exec "Kingdee.PLM.SystemConverter.exe" "ImportToTaskOut,OrCAD" &
}
proc MaterialMatchInDesign { pLib } {
	exec "Kingdee.PLM.SystemConverter.exe" "MaterialMatch,OrCAD" &
}
proc UpdatePropertysInDesign { pLib } {
	UpdateProperty
	exec "Kingdee.PLM.SystemConverter.exe" "ShowMassage,OrCAD" &
}


proc capTrue { } {
	return 2
}

}

::capTCLMenu::addDesignAccessoryMenu
RegisterAction "_cdnCapTclAddPageCustomMenu" "::capTCLMenu::capTrue" "" "::capTCLMenu::addPageAccessoryMenu" ""
RegisterAction "_cdnCapTclAddDesignCustomMenu" "::capTCLMenu::capTrue" "" "::capTCLMenu::addDesignAccessoryMenu" ""